package math

import "jvmgo/ch07/instructions/base"
import "jvmgo/ch07/rtda"

// 局部变量表中的int增加一个常数
type IINC struct {
    Index uint
    Const int32
}

func (self *IINC) FetchOperands(reader *base.BytecodeReader) {
    self.Index = uint(reader.ReadUint8())
    self.Const = int32(reader.ReadInt8())
}

func (self *IINC) Execute(frame *rtda.Frame) {
    localVars := frame.LocalVars()
    val := localVars.GetInt(self.Index)
    val += self.Const
    localVars.SetInt(self.Index, val)
}
